<div class="filter">
</div>
<table class="tablesorter" id="tab1">
	<thead>
		<tr>
			<th class="col_date">Date<span class="close">X</span></th>
			<th class="col_send">Send<span class="close">X</span></th>
			<th class="col_open">Open<span class="close">X</span></th>
			<th class="col_cofferclick">Offer Click<span class="close">X</span></th>
			<th class="col_offercompleted">Offer Completed<span class="close">X</span></th>
		</tr>
	</thead>
	<tbody>
	<?php if((!empty($reportItems)) && $reporttype=="6"): ?>
	<?php foreach ($reportItems as $k=>$reportItem):
			$date['start'] = $reportItem['date'];
			if($interval == 2){
				list($year, $week) = str_split($reportItem['date'], 4);
				$date = Util::getStartAndEndDate($week, $year);
			}
	?>
		<tr>
			<td class="col_date"><?php echo $date['start'];?> <?php if($interval==2){ echo '---'.$date['end'];} ?></td>
			<td class="col_send"><?php echo isset($reportItem['email_sent'])? $reportItem['email_sent'] : 0; ?></td>
			<td class="col_open"><?php echo isset($reportItem['email_open'])? $reportItem['email_open'] : 0; ?></td>
			<td class="col_cofferclick"><?php echo isset($reportItem['email_click'])? $reportItem['email_click'] : 0; ?></td>
			<td class="col_offercompleted"><?php echo isset($reportItem['email_offer_complete'])? $reportItem['email_offer_complete'] : 0; ?></td>
		</tr>
	<?php endforeach;?>
	<?php endif;?>
	</tbody>
</table>

<script type="text/javascript" src="<?php echo JS_DIR; ?>jquery.tablesorter.js"></script>
<script type="text/javascript" src="<?php echo JS_DIR; ?>jquery.uitablefilter.js"></script>
<script type="text/javascript">
	var $table = $('#tab1');
	$table.tablesorter({sortList: [[0,0]]});

	$('#ad_filter').click(function(){
		var id_to_header={
						  "ad_sites":"Site"
					   	 };
		
		var $table = $('#tab1');
		var filters = new Array();
	    var elems = $('.filters_col');
	    elems.each(function(){
			var elem = $(this);
			if(elem.css('display') != 'none'){
				if(elem.val() != ""){
					filters[elem.val()] = id_to_header[elem.attr('id')];
				}
			}
		});
		console.log(filters);
	    $.uiTableFilter( $table, filters);
	});
	
</script>
